#include "../comm.h"
class Solution {
public:
    vector<int> findMissingAndRepeatedValues(vector<vector<int>>& grid) {
        int n = grid.size();
        vector<int> flag(n * n + 1, 0);
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                flag[grid[i][j]]++;
        vector<int> ans(2);
        for (int i = 1; i <= n * n; ++i)
            if (flag[i] == 0)
                ans[1] = i;
            else if (flag[i] == 2)
                ans[0] = i;
        return ans;
    }
};